package com.jht.btconnect.common;

import android.content.Context;

import com.jht.btconnect.R;

import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class AttributeLookup {
    private Map<UUID, String> mUuidMap;
    private Context mContext = null;

    public AttributeLookup(Context context) {
        mContext = context;
        mUuidMap = new HashMap<UUID, String>();

        String[] uuids = context.getResources().getStringArray(R.array.uuids);
        for (String entry : uuids) {
            String[] parts = entry.split("\\|");
            if (parts.length == 2) mUuidMap.put(UUID.fromString(parts[0]), parts[1]);
        }
    }

    public String getService(UUID uuid) {
        if (mUuidMap.containsKey(uuid)) return mUuidMap.get(uuid);
        return mContext.getString(R.string.unknown_service);
    }

    public String getCharacteristic(UUID uuid) {
        if (mUuidMap.containsKey(uuid)) return mUuidMap.get(uuid);
        return mContext.getString(R.string.unknown_char);
    }

}

